import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import menus from './modules/menus'

Vue.use(Vuex)

const req = require.context('./modules', false, /\.js$/)
console.log(req)

const mName = req.keys().map(item => item.replace('./', '').replace('.js', ''))
console.log(mName)

const obj = {}

const mModule = req.keys().map(req)
console.log(mModule)

mName.forEach((item, index) => {
  console.log(item, index)
  obj[item] = mModule[index].default
})

const store = new Vuex.Store({
  modules: obj,
  getters,
  menus
})

export default store
